package org.liziing.shortlink.project.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.liziing.shortlink.project.dao.entity.LinkStatsTodayDO;
/**
 * 短链接今日统计持久层
 */
public interface LinkStatsTodayMapper extends BaseMapper<LinkStatsTodayDO> {

    @Insert("INSERT INTO t_link_stats_today (gid, full_short_url, date, today_pv, today_uv, today_uip, create_time, update_time, del_flag)" +
            "VALUES(#{linkStatsTodayStats.gid}, #{linkStatsTodayStats.fullShortUrl}, #{linkStatsTodayStats.date}, #{linkStatsTodayStats.todayPv}, #{linkStatsTodayStats.todayUv},#{linkStatsTodayStats.todayUip}, NOW(), NOW(), 0) " +
            "ON DUPLICATE KEY UPDATE today_pv = today_pv + #{linkStatsTodayStats.todayPv}, " +
            "today_uv = today_uv + #{linkStatsTodayStats.todayUv}," +
            "today_uip = today_uip + #{linkStatsTodayStats.todayUip};")
    void insertLinkTodayStats(@Param("linkStatsTodayStats") LinkStatsTodayDO linkStatsTodayStats);
}
